*This file creates event studies without established sectors Figure D.4

use  "$path/ind_ddd.dta", clear

* Defining control variables

global sharecontrols c.lnlabor_all1943#year c.power_labor_share1943#year c.ln_relative_wage1943#year c.ln_establishments1943#year c.skilled1943#year c.ln_inputs_all1943#year c.ln_valueadded1943#year 

global sharecontrols2 c.ln_value_prod1943#year c.lnlabor_all1943#year 

drop repa*

global treat treat_std_l3

drop if year==1970 // Not in Norway

forvalues x=34/69 {
gen ydum19`x'=0
replace ydum19`x'=1 if year==19`x'
}

forvalues x=34(1)69{
	gen repam19`x'=ydum19`x'*$treat
	}

	forvalues x=34(1)69{
	gen repaml19`x'=ydum19`x'*finland*$treat
	}
	
forvalues x=34(1)69{
	gen fin19`x'=ydum19`x'*finland
	}

********
*Robustness Figure D.6
*Without timber paper
********

preserve

use  "$path/industry_data.dta", clear

***Panel B: scaled_prod_c pic
forvalues x=34(1)70{
	gen repam19`x'=ydum19`x'*treat_std_l 
	}

local joku "1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970"

foreach l of local joku {
label var repam`l'  `l'
}

global sharecontrols c.lnlabor_all1943#year  c.power_labor_share1943#year c.ln_relative_wage1943#year c.ln_establishments1943#year c.skilled1943#year c.ln_inputs_all1943#year c.ln_valueadded1943#year 


local repaflexible1 " repam1934 repam1935 repam1936 repam1937 repam1938 repam1939 repam1940 repam1941 repam1942 repam1944 repam1945 repam1946 repam1947 repam1948 repam1949 repam1950 repam1951 repam1952 repam1953 repam1954 repam1955 repam1956 repam1957 repam1958 repam1959 repam1960 repam1961 repam1962 repam1963 repam1964 repam1965 repam1966 repam1967 repam1968 repam1969 repam1970  "
tempfile  p1 p11 p12 

parmby  "reghdfe ln_value_prod  `repaflexible1' if timberpaper==0, absorb(year isic  $sharecontrols) vce(cluster isic)", lab saving(`"`p1'"',replace) idn(1) ids(Unadjusted)

clear all
set obs 1
gen year =1943
gen estimate = 0
gen parm ="repam1943"
gen min95 =0
gen max95 =0
append using `p1'
keep if regexm(parm, "^repa*")
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr
tempfile tprod1
save `tprod1'

twoway (scatter estimate yearstr , msize(medium) mcolor(dknavy))  (rspike   min95 max95 yearstr , lcolor(dknavy)),  xsize(6) ysize(4) xtitle(Year, ) xline(1944, lcolor(maroon)) xline(1952, lcolor(maroon)) title("Difference-in-Difference Estimates of ln Value of Production")  ///
 xlabel(1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970, ) plotregion(lcolor(white)) graphregion(lcolor(white) fcolor(white) color(white)) legend(off)  xlabel(#8)  ylabel(-.2 0 .2 .4) ytick(-.2 0 .2 .4, )  ytitle("", margin(0 1 0 0))   saving(flexible_prod_fin2.gph, replace)
restore

preserve

use  "$path/industry_data.dta", clear


forvalues x=34(1)70{
	gen repam19`x'=ydum19`x'*treat_std_l 
	}

	
local year "1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970"

foreach l of local year {
label var repam`l'  `l'
}


global sharecontrols c.lnlabor_all1943#year  c.power_labor_share1943#year c.ln_relative_wage1943#year c.ln_establishments1943#year c.skilled1943#year c.ln_inputs_all1943#year c.ln_valueadded1943#year  c.ln_value_prod1943#year 

local repaflexible1 " repam1934 repam1935 repam1936 repam1937 repam1938 repam1939 repam1940 repam1941 repam1942 repam1944 repam1945 repam1946 repam1947 repam1948 repam1949 repam1950 repam1951 repam1952 repam1953 repam1954 repam1955 repam1956 repam1957 repam1958 repam1959 repam1960 repam1961 repam1962 repam1963 repam1964 repam1965 repam1966 repam1967 repam1968 repam1969 repam1970  "
tempfile  p1 p11 p12 

parmby  "reghdfe lnlabor_all  `repaflexible1' if timberpaper==0, absorb(year isic  $sharecontrols) vce(cluster isic)", lab saving(`"`p11'"',replace) idn(1) ids(Unadjusted)


clear all
set obs 1
gen year =1943
gen estimate = 0
gen parm ="repam1943"
gen min95 =0
gen max95 =0
append using `p11'
keep if regexm(parm, "^repa*")
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr
tempfile tlabor1
save `tlabor1'


twoway (scatter estimate yearstr , msize(medium) mcolor(dknavy))  (rspike   min95 max95 yearstr , lcolor(dknavy)),  xsize(6) ysize(4) xtitle(Year, ) xline(1944, lcolor(maroon)) xline(1952, lcolor(maroon)) title("Difference-in-Difference Estimates of ln Labor Force")  ///
 xlabel(1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970, ) plotregion(lcolor(white)) graphregion(lcolor(white) fcolor(white) color(white)) legend(off)  xlabel(#8)  xlabel(, nogextend )  ytick(-.2 0 .2 .4) ytitle("", margin(0 1 0 0))   saving(flexible_labor_fin2.gph, replace)
restore

local joku "1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969"

foreach l of local joku {
label var repam`l'  `l'
}

local repaflexible " repam1934 repam1935 repam1936 repam1937 repam1938 repam1939 repam1940 repam1941 repam1942  repam1944 repam1945 repam1946 repam1947 repam1948 repam1949 repam1950 repam1951 repam1952 repam1953 repam1954 repam1955 repam1956 repam1957 repam1958 repam1959 repam1960 repam1961 repam1962 repam1963 repam1964 repam1965 repam1966 repam1967 repam1968 repam1969  "

local repaflexible2 " repaml1934 repaml1935 repaml1936 repaml1937 repaml1938 repaml1939 repaml1940 repaml1941 repaml1942  repaml1944 repaml1945 repaml1946 repaml1947 repaml1948 repaml1949 repaml1950 repaml1951 repaml1952 repaml1953 repaml1954 repaml1955 repaml1956 repaml1957 repaml1958 repaml1959 repaml1960 repaml1961 repaml1962 repaml1963 repaml1964 repaml1965 repaml1966 repaml1967 repaml1968 repaml1969  "

local finflex " fin1934 fin1935 fin1936 fin1937 fin1938 fin1939 fin1940 fin1941 fin1942  fin1944 fin1945 fin1946 fin1947 fin1948 fin1949 fin1950 fin1952 fin1953 fin1954 fin1955 fin1956 fin1957 fin1958 fin1959 fin1960 fin1961 fin1962 fin1963 fin1964 fin1965 fin1966 fin1967 fin1968 fin1969  "

tempfile t1 t2 t3 t4

parmby  "reghdfe ln_value_prod  `repaflexible'  `repaflexible2' `finflex' if timberpaper==0, absorb(year_country isic_country   $sharecontrols2) vce(cluster isic_country)", lab saving(`"`t1'"',replace) idn(1) ids(Unadjusted)


parmby  "reghdfe lnlabor_all  `repaflexible' `repaflexible2'  `finflex' if timberpaper==0, absorb(year_country isic_country   $sharecontrols2) vce(cluster isic_country)", lab saving(`"`t2'"',replace) idn(1) ids(Unadjusted)

	
preserve

clear all
set obs 1
gen year =1943
gen estimate = 0
gen parm ="repaml1943"
gen min95 =0
gen max95 =0
append using `t1'
keep if regexm(parm, "^repa*")
keep if _n>35|year ==1943
drop if parmseq==35
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr
twoway  (scatter estimate  yearstr, msize(medium) mcolor(dknavy)) (rspike   min95 max95 yearstr , lcolor(dknavy)), xsize(6) ysize(4) xtitle(Year, size(medium)) xline(1944) xline(1952) title("Triple-Difference Estimates of  ln Value of Production")  ///
 xlabel(1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 ///
 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 ) plotregion(lcolor(white)) graphregion(lcolor(white) fcolor(white) color(white)) legend(off)  xlabel(#8)   ylabel(,grid nogextend) ytick(-.2 0 .2 .4)   ytitle("", margin(0 1 0 0))  saving(prod_ddd2.gph, replace)
 
restore  
 
preserve

clear all
set obs 1
gen year =1943
gen estimate = 0
gen parm ="repaml1943"
gen min95 =0
gen max95 =0
append using `t2'
keep if regexm(parm, "^repa*")
keep if _n>35|year ==1943
drop if parmseq==35
gen yearstr =substr(parm, -4,4)
destring yearstr, replace
sort yearstr
twoway  (scatter estimate  yearstr, msize(medium) mcolor(dknavy)) (rspike   min95 max95 yearstr , lcolor(dknavy)), xsize(6) ysize(4) xtitle(Year, size(medium)) xline(1944) xline(1952) title("Triple-Difference Estimates of  ln Labor Force")  ///
xlabel(1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970, ) plotregion(lcolor(white)) graphregion(lcolor(white) fcolor(white) color(white)) legend(off) ytick(-.2 0 .2 .4)   xlabel(#8)   ylabel(,grid nogextend)  ytitle("", margin(0 1 0 0))   saving(labor_ddd2.gph, replace)
restore	

graph combine flexible_prod_fin2.gph prod_ddd2.gph ,  col(2) iscale(.8) ysize(5) xsize(15)commonscheme graphregion(fcolor(white) color(white))

graph export "$graphs/combined_DDD_prod2ntp.eps",as(eps)   font(Times) replace
graph export "$graphs/combined_DDD_prod2ntp.pdf",as(pdf)   font(Times) replace

graph combine flexible_labor_fin2.gph labor_ddd2.gph ,  col(2) iscale(.8) ysize(5) xsize(15) commonscheme  graphregion(fcolor(white) color(white))

graph export "$graphs/combined_DDD_l2ntp.eps",as(eps)   font(Times) replace
graph export "$graphs/combined_DDD_l2ntp.pdf",as(pdf)   font(Times) replace


